package cn.com.unionlife.hy.media.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.unionlife.hy.core.exception.BusinessException;
import cn.com.unionlife.hy.media.mapper.MediaMapper;
import cn.com.unionlife.hy.media.service.MediaTranService;
import cn.com.unionlife.hy.media.vo.MediaVO;

@Transactional(rollbackFor = Exception.class)
@Service("mediaTranService")
public class MediaTranServiceImpl implements MediaTranService {

	@Resource(name = "mediaMapper")
	private MediaMapper mediaMapper;
	@Override
	public MediaVO addMedia(MediaVO vo) {
		//TODO 校验
		vo.setCreateDate(new Date());
		vo.setUpdateDate(new Date());
		vo.setDr(false);
		mediaMapper.insert(vo);
		return vo;
	}
	@Override
	public void deleteMediaById(Long id) {
		mediaMapper.delete(id);
	}
	@Override
	public MediaVO updateMedia(MediaVO vo) throws BusinessException {
		vo.setUpdateDate(new Date());
		mediaMapper.update(vo);
		return vo;
	}

}
